import tensor as ts
import numpy as np
import multiprocessing as mp

def ReLU(a):
	return a.ReLU()

def sigmoid(a):
	return a.sigmoid()

def tanh(a):
	return a.tanh()

def softplus(a):
	return a.softplus()

def softsign(a):
	return a.softsign()

def matmul(a,b):
	return a.matmul(b)

def add(a,b):
	return a+b

def simpleConv2d(img,kernels=None,kernelshape=(1,1,2,2)):
	return img.simpleConv2d(kernels=kernels,kernelshape=kernelshape)

def conv2d(img,kernel=None,kernelshape=(1,2,2)):
	return img.simpleConv2d(kernel=kernels,kernelshape=kernelshape)

def maxPool2d(img,poolSize=(2,2)):
	return img.maxPool2d(poolSize)

def avgPool2d(img,poolSize=(2,2)):
	return img.avgPool2d(poolSize)

def reshape(a,shape):
	return a.reshape(shape)

def MSELoss(a,feature):
	return a.MSELoss(feature)

def softmax_crossEntropy(a,feature):
	return a.softmax_crossEntropy(feature)

def nop(a):
	return a


def conversion(y,maxi):
	"""
	y.shape->(n,1)
	out.shape->(n,maxi)
	"""
	out = np.zeros((y.shape[0],maxi+1))
	for i in range(y.shape[0]):
		out[i,y[i]] = 1
	return out



funcDict = {'matmul':matmul,
			'add':add,
			'simpleConv2d':simpleConv2d,
			'conv2d':conv2d,
			'maxPool2d':maxPool2d,
			'avgPool2d':avgPool2d,
			'reshape':reshape,
			'ReLU':ReLU,
			'sigmoid':sigmoid,
			'tanh':tanh,
			'softplus':softplus,
			'softsign':softsign,
			'MSELoss':MSELoss,
			'softmax_crossEntropy':softmax_crossEntropy
			}























